<!DOCTYPE html>
<html>
	<head>
		<title></title>
	</head>
	<body>
		<script>
		  var users=["Mary","Ben","Lily","Alice"];
		  var passes=["1234","2234","3234","4234"];
		  var login = false;
		  var rightname = null;
		  var pwd = null;
		  for(var i=0;i<3;i++)
		  {
			  var username = "";
			  if (rightname == false)
				username=prompt("用户名错误，请重新输入用户名：");
			  else
				username=prompt("请输入用户名：");
			  for(var j=0;j<users.length;j++)
			  {
				  if(username == users[j])
				  {
					  rightname = true;
					  for(var k=0; k<3;k++)
					  {
						  var password = "";
						 if(pwd == false)
							password=prompt("密码错误，请重新输入密码：");
						 else
							password=prompt("请输入密码：");
						 if(password == passes[j])
						 {
							 pwd = true;
							 document.write("Login successed!"); 
							 login = true;
							 break;  
						 }
						 else{
							 document.write("password error!");
							 pwd = false;
						 }
					  }
				  }
			  }
			  if(!rightname)
			  {
				  rightname = false;
				  document.write("username error!\n");
				  continue;
			  }
			  
			  if (login)
			  {
				  break;
			  }
			  else
			  {
				  continue;
			  }
		  }
			</script>
	</body>
</html>